//
//  LH24HoursFirstCell.m
//  Project_B
//
//  Created by dllo on 15/12/26.
//  Copyright © 2015年 ZY. All rights reserved.
//

#import "LH24HoursFirstCell.h"

@implementation LH24HoursFirstCell
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createViews];
    }
    return self;
}

#pragma mark- 重写方法
- (void)createViews
{
    
    // 图片
    _imageV = [UIImageView new];
    [self.contentView addSubview:_imageV];
    [_imageV mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.top.equalTo(@10);
        make.size.mas_equalTo(CGSizeMake(SCREEN_WIDTH-20, SCREEN_HEIGHT/7*2-30));
        
    }];
    
    
    // 标题
    _titleL = [UILabel new];
    _titleL.font = [UIFont systemFontOfSize:18 * ADAPT_FONT];
    [self.contentView addSubview:_titleL];
    [_titleL mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(_imageV);
        make.top.equalTo(_imageV.mas_bottom).offset(15);
        make.size.mas_equalTo(CGSizeMake(SCREEN_WIDTH, 30));
        
    }];
    
    // 详情
    _digestL = [UILabel new];
    _digestL.font = [UIFont systemFontOfSize:16 * ADAPT_FONT];
    _digestL.numberOfLines = 0;
    [self.contentView addSubview:_digestL];
    [_digestL mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(_titleL);
        make.top.equalTo(_titleL.mas_bottom).offset(10);
        make.size.mas_equalTo(CGSizeMake(SCREEN_WIDTH-20, 40));
        
    }];
    
    // 跟贴
    _replyL = [UILabel new];
    _replyL.font = [UIFont systemFontOfSize:14 * ADAPT_FONT];
    _replyL.textColor = [UIColor grayColor];
    _replyL.textAlignment = NSTextAlignmentRight;
    [self.contentView addSubview:_replyL];
    [_replyL mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.bottom.offset(-10);
        make.size.mas_equalTo(CGSizeMake(80, 10));
        
    }];
    
    
    //隔断
    UILabel *downL = [UILabel new];
    downL.backgroundColor = [UIColor colorWithWhite:0.703 alpha:1.000];
    [self.contentView addSubview:downL];
    [downL mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(@0);
        make.bottom.equalTo(@(0));
        make.size.mas_equalTo(CGSizeMake(SCREEN_WIDTH, 2));
        
    }];

    
}

- (void)setModel:(LH24HoursModel *)model
{
    //图片
    [_imageV sd_setImageWithURL:[NSURL URLWithString:model.imgsrc] placeholderImage:PLACEHOLDER_IMAGE];
    
    // 标题
    _titleL.text = model.title;
    
    // 简介
    _digestL.text = model.digest;
    
    // 判断跟贴
    if (nil != [NSString stringWithFormat:@"%@", model.replyCount]) {
        
        _replyL.text = [NSString stringWithFormat:@"%@跟帖", model.replyCount];
        
    } else {
        
        _replyL.text = @"专题";
        
    }
    
}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
